package com.lzl.eduservice.controller;


import com.lzl.common_utils.R;
import com.lzl.eduservice.entity.EduVideo;
import com.lzl.eduservice.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-03-30
 */
@RestController
@RequestMapping("/eduservice/video")
//@CrossOrigin
public class EduVideoController {

    @Autowired
    private EduVideoService eduVideoService;

    //添加小节
    @PostMapping("addVideo")
    public R addVideo(@RequestBody EduVideo eduVideo){

        eduVideoService.save(eduVideo);
        return R.ok();
    }

    /**
     * 删除小节
     * TODO1 还未完善：删除小节的时候，需要把小节里面的视频也删除了
     * 现在完善了
     * @param videoId
     * @return
     */
    @DeleteMapping("deleteVideo/{videoId}")
    public R deleteVideoById(@PathVariable String videoId){
//         eduVideoService.removeById(videoId);

        eduVideoService.deleteVideoById(videoId);
         return R.ok();
    }


    //修改小节 TODO


}

